package com.xinhe.cn.cpbox.controller;


import com.alibaba.fastjson.JSONObject;
import com.xinhe.cn.cpbox.service.ManagementService;
import com.xinhe.cn.cpbox.service.MoonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author HB
 * @date 2021-03-22
 */
@Api(value = "管理端相关接口", tags = {"管理端相关接口"})
@RestController
@RequestMapping("/management")
public class ManagementController {
    @Autowired
    ManagementService managementService;
    @Autowired
    MoonService moonService;

    @ApiOperation(value = "管理端测试接口", notes = "管理端测试接口")
    @GetMapping("/test")
    public Object test() {
        return managementService.test();
    }

    @ApiOperation(value = "登陆", notes = "登陆")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名", dataTypeClass = int.class),
            @ApiImplicitParam(name = "password", value = "密码", dataTypeClass = int.class)
    }
    )
    @PostMapping("login")
    public Object login(@RequestBody @ApiIgnore JSONObject jsonObject) {
        return managementService.login(jsonObject);
    }

    @ApiOperation(value = "修改客服二维码url", notes = "修改客服二维码url")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "codeUrl", value = "二维码图片的url", dataTypeClass = int.class)
    }
    )
    @PostMapping("changeServiceQrCode")
    public Object changeServiceQrCode(@RequestBody @ApiIgnore JSONObject jsonObject) {
        return moonService.changeServiceQrCode(jsonObject);
    }

    @ApiOperation(value = "分页查询发出提现申请的月老的信息", notes = "分页查询发出提现申请的月老的信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "查询类型：-1/0/1，全部/已处理/未处理(默认应传1)", dataTypeClass = String.class),
            @ApiImplicitParam(name = "page", value = "页码，从1开始", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "size", value = "每页个数", dataTypeClass = Integer.class)
    })
    @GetMapping("/getCashOutApply")
    public Object getCashOutApply(@RequestParam("type") int type,
                                  @RequestParam("page") int page,
                                  @RequestParam("size") int size) {
        return managementService.getCashOutApply(type, page, size);
    }

    @ApiOperation(value = "提现申请成功后，点击按钮完成该申请", notes = "提现申请成功后，点击按钮完成该申请")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "matchMakerId", value = "发起提现的月老的id", dataTypeClass = String.class),
            @ApiImplicitParam(name = "money", value = "提现成功的金额", dataTypeClass = String.class)
    }
    )
    @PostMapping("completeMoneyApply")
    public Object completeMoneyApply(@RequestBody @ApiIgnore JSONObject jsonObject) {
        return managementService.completeMoneyApply(jsonObject);
    }

    @ApiOperation(value = "分页查询纸条", notes = "分页查询纸条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "查询类型：-1/0/1/2，全部/未审核(默认应传0)/审核通过/审核未通过", dataTypeClass = String.class),
            @ApiImplicitParam(name = "page", value = "页码，从1开始", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "size", value = "每页个数", dataTypeClass = Integer.class)
    })
    @GetMapping("/getScrip")
    public Object getScrip(@RequestParam("type") int type,
                           @RequestParam("page") int page,
                           @RequestParam("size") int size) {
        return managementService.getScrip(type, page, size);
    }

    @ApiOperation(value = "修改纸条审核状态", notes = "修改纸条审核状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "scripId", value = "纸条的id", dataTypeClass = String.class),
            @ApiImplicitParam(name = "checked", value = "审核状态: 1/2，通过/不通过", dataTypeClass = String.class)
    }
    )
    @PostMapping("checkScrip")
    public Object checkScrip(@RequestBody @ApiIgnore JSONObject jsonObject) {
        return managementService.checkScrip(jsonObject);
    }
}